# encoding: utf-8
"""
@author: lee
@time: 2019/5/10 14:55
@file: main.py.py
@desc:
"""
import pandas as pd
from fbprophet import Prophet
from pandas.plotting import register_matplotlib_converters
import sys


def main():
    # python main.py C:/Users/佳奇/Desktop/testfff/front/front_count.csv asdcas
    df = pd.read_csv(sys.argv[1])
    print(df.head())
    m = Prophet()
    m.fit(df)

    future = m.make_future_dataframe(periods=15)
    # 打印预测的后几天 日期
    print(future.tail())
    # 预测完的数据
    forecast = m.predict(future)
    print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail())
    # print(forecast)
    register_matplotlib_converters()
    fig1 = m.plot(forecast)
    # fig1.show()
    fig1.savefig('./static/images/'+sys.argv[2]+'.png')
    fig1.close()
    # fig2 = m.plot_components(forecast)
    # fig2.show()
    sys.stdout.flush()



if __name__ == "__main__":
    main()
